from leapp.actors import Actor
from leapp.libraries.common.rpms import has_package
from leapp.models import InstalledRedHatSignedRPM
from leapp.reporting import Report, create_report
from leapp import reporting
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag


class CheckTomcat(Actor):
    """
    Check if tomcat is installed. If yes, write information about important changes.
    """

    name = 'checktomcat'
    consumes = (InstalledRedHatSignedRPM,)
    produces = (Report,)
    tags = (ChecksPhaseTag, IPUWorkflowTag)

    def process(self):
        if has_package(InstalledRedHatSignedRPM, 'tomcat'):
            create_report([
                reporting.Title('Changes of deploying tomcat in Anolis 8'),
                reporting.Summary(
			'In Anolis 8, tomcat package is removed, tomcat contains the following commands:tomcat, tomcat-digest, tomcat-tool-wapper.\n'
			'But tomcat is also compatible with Anolis 8,  you can downlaod and install manually.\n'
			'Please refer to "https://openanolis.cn/sig/third_software_compatibility/doc/392149640260550929".'
                ),
                reporting.Severity(reporting.Severity.LOW),
                reporting.RelatedResource('package', 'tomcat')
            ])
